package com.wenx.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * Created by wenx on 2019-10-19 15:25
 */
public class SingletionTest {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

        Singleton instance = Singleton.getInstance();
        System.out.println("instance = " + instance);

        Class<?> aClass = Class.forName("com.wenx.reflect.Singleton");
        Constructor<?> constructor = aClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        Singleton newInstance = (Singleton)constructor.newInstance();
        System.out.println("newInstance = " + newInstance);

    }
}